using DimensionsHelper.LanguageService.Syntax;

namespace DimensionsHelper.LanguageService;

public class AnalysisExitStatement : AnalysisStatement
{
    internal AnalysisExitStatement(ExitStatement syntaxNode, AnalysisNode? parent) : base(
        AnalysisBoundKinds.ExitStatement, syntaxNode, parent)
    {
        Syntax = syntaxNode;
    }

    public override ExitStatement Syntax { get; }

    public override int ChildrenCount => 0;

    public override IEnumerable<AnalysisNode> GetChildren()
    {
        return Array.Empty<AnalysisNode>();
    }

    internal override void AddChild(AnalysisNode child)
    {
        throw new NotSupportedException("AnalysisExitStatement is read-only.");
    }
}


public static partial class AnalysisNodeFactory
{
    /// <summary>
    /// 创建一个Exit语句
    /// </summary>
    /// <param name="syntaxNode">原始语法节点</param>
    /// <param name="parent">父节点，可以忽略</param>
    public static AnalysisExitStatement ExitStatement(ExitStatement syntaxNode, AnalysisNode? parent)
    {
        return new AnalysisExitStatement(syntaxNode, parent);
    }
}